package com.cheng.im.gateway.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.apache.rocketmq.spring.support.RocketMQMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.converter.*;
import org.springframework.util.ClassUtils;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class MQConfig {

//    @Bean
//    public RocketMQMessageConverter messageConverter() {
//
//        return new RocketMQMessageConverterProtoBuf();
//    }
    
    
    public class RocketMQMessageConverterProtoBuf extends RocketMQMessageConverter {

        private final CompositeMessageConverter messageConverter;

        public RocketMQMessageConverterProtoBuf() {
            List<MessageConverter> messageConverters = new ArrayList<>();
            ProtobufMessageConverter protobufMessageConverter = new ProtobufMessageConverter();
            messageConverters.add(protobufMessageConverter);

            this.messageConverter = new CompositeMessageConverter(messageConverters);
        }

        @Override
        public MessageConverter getMessageConverter() {
            return messageConverter;
        }
    }
}
